﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Zor_DAL;
using Zor_Modes;
using Zor_Tools;

namespace Zor_Bll
{
    public class PrayAcceptance_Bll<T> where T : class
    {

        /// <summary>
        /// 获取列表
        /// </summary>
        /// <param name="index">页码</param>
        /// <param name="TotalCount">返回值</param>
        /// <returns></returns>
        public static List<T> GetPageList(dynamic Model, int index, out int TotalCount, string where)
        {
            var sqlSurch = string.Empty;
            if (Model.Acceptance_TicketNumber != null)
            {
                sqlSurch += " Acceptance_TicketNumber like '%" + Model.Acceptance_TicketNumber + "%' and ";
            }
            if (Model.NatPer_Name != null)
            {
                sqlSurch += " NatPer_Name like '%" + Model.NatPer_Name + "%' and ";
            }
            if (Model.Acceptance_TaxNumber != null)
            {
                sqlSurch += " Acceptance_TaxNumber like '%" + Model.Acceptance_TaxNumber + "%' and ";
            }
            if (Model.Tenant_Name != null)
            {
                sqlSurch += "Tenant_Name like '%" + Model.Tenant_Name + "%' and ";
            }
            sqlSurch += " Dt_Id = " +RequestSession.GetSessionUser().DT_Id+" ";
            return PagerHelp<T>.GetPagerList(index, "V_PrayAcceptance", "Acceptance_CreateTime desc ", out TotalCount, sqlSurch);
        }

        /// <summary>
        /// 获取租赁管理列表（不分页）
        /// create 刘云飞 by 2017/04/06       
        /// </summary>
        /// <returns></returns>
        public static List<T> GetList(dynamic Model, string where)
        {
            var sqlSurch = string.Empty;
            if (Model.Acceptance_TicketNumber != null)
            {
                sqlSurch += " Acceptance_TicketNumber like '%" + Model.Acceptance_TicketNumber + "%' and ";
            }
            if (Model.NatPer_Name != null)
            {
                sqlSurch += " NatPer_Name like '%" + Model.NatPer_Name + "%' and ";
            }
            if (Model.Acceptance_TaxNumber != null)
            {
                sqlSurch += " Acceptance_TaxNumber like '%" + Model.Acceptance_TaxNumber + "%' and ";
            }
            if (Model.Tenant_Name != null)
            {
                sqlSurch += "Tenant_Name like '%" + Model.Tenant_Name + "%' and ";
            }
            sqlSurch += " Dt_Id = " + RequestSession.GetSessionUser().DT_Id + " ";
            return PrayWarn_DAL<T>.SelectViewPrayAcceptance(sqlSurch);
        }
    }
}
